
export default function Controller(url) {
    return function (target, name, descriptor) {
        if(!target.name){
            let obj= qguan(target.constructor.name)
            let rule=new  Rule(target.constructor.name,name,new RegExp("^"+url) )
            if(!obj){
                obj=   new target.constructor();
                qguan(target.constructor.name,obj,null,'save') ;
            }
            applicationContext.addBend(rule);
        }else {
            for(let i=0;i< applicationContext.bendArray.length;i++){
                let bend= applicationContext.bendArray[i];
                if(bend.className==target.name&&bend.type=="http"){
                    let _str=applicationContext.bendArray[i].reg.source
                    let str=url+_str.substring(1,_str.length);
                    applicationContext.bendArray[i].reg=new RegExp("^"+str);
                }
            }
        }
    }
}

/**
 * 规则信息
 * 执行前的条件
 */
 class Rule{
    constructor(className,method,reg,type){
        this.className=className?className:"";//类
        this.method=method?method:"";// 方法
        this.reg=reg?reg:"*" ;//方法正则
        this.type=type?type:"http";
    }

}
